//
//  DataBaseFouceStarModel.m
//  WULIHH
//
//  Created by tang on 16/4/5.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "DataBaseFouceStarModel.h"
#import "Header.h"
#import "FMDB.h"

@interface DataBaseFouceStarModel ()
{
    FMDatabase *db;
}

@end


@implementation DataBaseFouceStarModel


//打开数据库，若果表不存在，创建表
- (void)openDataBase
{
    
    //创建编辑图片数据库
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDirectory = [paths objectAtIndex:0];
    //    NSLog(@"%@", documentDirectory);
    NSString *dbPath = [documentDirectory stringByAppendingPathComponent:@"MyDatabase.db"];
    db = [FMDatabase databaseWithPath:dbPath] ;
    if (![db open]) {
        NSLog(@"Could not open db");
        //        return ;
    }
    else
    {
        
        [db executeUpdate:@"CREATE TABLE IF NOT EXISTS FouceStarList (headImage text, SratID text, Name text)"];
    }

}



//写入明星数据
- (void)writeStarInfoWithName:(NSString *)name  withImage:(NSString *)imageUrl withID:(NSString *)stringID
{
    BOOL writeIsOK = [db executeUpdate:@"INSERT INTO FouceStarList (headImage, SratID, Name) VALUES (?, ?, ?)", imageUrl, stringID, name];
    if (writeIsOK)
    {
        
    }
    else
    {
        
    }
}


//读取明星数据,    获取id
- (void)getStarID:(getStarID)callBack
{
    
}

//删除关注明星
- (void)deleteStarWithInfoWithID:(NSString *)IDstring
{
    
}




//关闭数据库
- (void)closeDataBase
{
    
}



@end
